﻿<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeFile="Shop.aspx.cs" Inherits="Shop" %>

<%@ Register TagPrefix="uc" Namespace="Taopi.WebComponents" %>
<%--<%@ Register TagPrefix="uc" TagName="RatingLabel" Src="~/Components/RatingLabel.ascx" %>--%>
<%@ Register TagPrefix="uc" Namespace="Taopi.WebComponents" %>
<asp:content id="Content1" contentplaceholderid="head" runat="Server">
    <style type="text/css">
        section
        {
            margin: 10px 0;
        }
        .fieldAlign
        {
            margin-left: 50px;
        }
        #coverpic
        {
            display: inline-block;
            vertical-align: top;
            margin-top: 1em;
        }
        #shortInfo
        {
            display: inline-block;
            margin-left: 50px;
        }
        #shortInfo > *
        {
            margin: 1em 0;
        }
        
        #shopName
        {
            margin: 0 0 1em 0;
        }
        
        #shopDescription
        {
            min-height: 50px;
        }
        .closeDescription
        {
            float: right;
        }

    </style>
</asp:content>
<asp:content id="Content2" contentplaceholderid="MainContent" runat="Server">
    <asp:SqlDataSource ID="shortInfoSource" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
        
        
        
        SelectCommand="SELECT Shop.name, Category.name AS category, Shop.Description, ISNULL(SUM(SalesItem.rating) * 1.0 / COUNT(*), 0) AS rating, aspnet_Users.UserName AS shopOwner FROM Shop INNER JOIN Product ON Shop.name = Product.Shop INNER JOIN Category ON Shop.category = Category.name INNER JOIN aspnet_Users ON Shop.owner = aspnet_Users.UserId INNER JOIN SalesItem ON Product.id = SalesItem.product WHERE (Shop.name = @name) GROUP BY Shop.name, Category.name, Shop.Description, aspnet_Users.UserName">
        <SelectParameters>
            <asp:QueryStringParameter Name="name" QueryStringField="n" />
        </SelectParameters>
    </asp:SqlDataSource>
    <section>
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="name" 
        DataSourceID="shortInfoSource" Width="100%">
            <%-- <EditItemTemplate>
                    name:
                    <asp:Label ID="nameLabel1" runat="server" Text='<%# Eval("name") %>' />
                    <br />
                    category:
                    <asp:TextBox ID="categoryTextBox" runat="server" Text='<%# Bind("category") %>' />
                    <br />
                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                        Text="更新" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
                        CommandName="Cancel" Text="取消" />
                </EditItemTemplate>>
                <InsertItemTemplate>
                    name:
                    <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' />
                    <br />
                    category:
                    <asp:TextBox ID="categoryTextBox" runat="server" Text='<%# Bind("category") %>' />
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                        Text="插入" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
                        CommandName="Cancel" Text="取消" />
                </InsertItemTemplate>--%>
            <ItemTemplate>
                <div id="coverpic">
                    <asp:Image ID="Image1" runat="server" Height="96px" Width="96px" ImageUrl="~/Images/shop.png" />
                </div>
                <div id="shortInfo">
                    <h2 id="shopName">
                        <%# Eval("name") %>
                    </h2>
                    <div>
                        <span>Shop owner</span>
                        <span><%# Eval("shopOwner") %></span>
                        <asp:Button ID="chatButton" runat="server" onClick="chatButton_Click" Text="Chat to me" />
                    </div>
                    <div>
                        <span>Rating</span>
                        <uc:RatingLabel Rating='<%# Eval("rating")%>' runat="server" />
                    </div>
                    <div>
                        <span>Category</span><asp:Label ID="Label1" runat="server" Text='<%# Eval("category") %>' />
                    </div>

                </div>
                <div id="shopDescription">
                <asp:CheckBox CssClass="closeDescription" ID="CheckBox1" runat="server" Text="收起" />
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("Description") %>'/>
                </div>
            </ItemTemplate>
        </asp:FormView>
    <br />
    </section>
                        <div>
                        <asp:Button ID="AddLikeButton" runat="server" Text="Like" 
                            onclick="AddLikeButton_Click" ViewStateMode="Disabled" Visible="False" />
                        <asp:Button ID="RemoveLikeButton" runat="server" onclick="RemoveLikeButton_Click" 
                            Text="Unlike" ViewStateMode="Disabled" Visible="False" />
                        </div>
    <section>
        <div class="leftNRight">
            <h3>
                Product List</h3>
            <span class="right">Sort by
                <asp:DropDownList ID="DropDownList1" runat="server">
                    <asp:ListItem>Sold Amount</asp:ListItem>
                    <asp:ListItem>Rating</asp:ListItem>
                    <asp:ListItem>Price</asp:ListItem>
                    <asp:ListItem>Discount</asp:ListItem>
                </asp:DropDownList>
            </span>
        </div>
        <asp:SqlDataSource ID="productsSource" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
            
        SelectCommand="SELECT Product.name, Product.Price, Product.Discount, Product.Description, Product.inventoryLevel, Product.coverPhoto FROM Product INNER JOIN Shop ON Product.Shop = Shop.name WHERE (Shop.name = @shopName)" >
            <SelectParameters>
                <asp:QueryStringParameter Name="shopName" QueryStringField="n" />
            </SelectParameters>
    </asp:SqlDataSource>
        <asp:DataList ID="DataList1" runat="server" DataKeyField="name" 
        DataSourceID="productsSource">
            <ItemTemplate>
                <%--<uc:ProductThumbnail runat="server" ProductName='<%# Eval("name") %>' Price='<%# Eval("Price") %>' />--%>
            </ItemTemplate>
        </asp:DataList>
    </section>
</asp:content>
